//
//  ViewController.m
//  05-在HTML中调用OC
//
//  Created by J on 16/2/18.
//  Copyright © 2016年 J. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UIWebViewDelegate,UINavigationControllerDelegate,UIPickerViewDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *webView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    NSURL* url = [[NSBundle mainBundle]URLForResource:@"index.html" withExtension:nil];
    NSURLRequest* requ = [NSURLRequest requestWithURL:url];
    [self.webView loadRequest:requ];
}

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
    NSString* str = request.URL.absoluteString;
    NSRange range = [str rangeOfString:@"xmg://"];
    if (range.location!=NSNotFound) {
        NSString* method = [str substringFromIndex:range.length];
        NSLog(@"%@",method);
//        SEL sel = NSSelectorFromString(method);
//        [self performSelector:sel];
    }
    
    return YES;

}


//访问相册
- (void)getImage{
    
    UIImagePickerController* vc = [[UIImagePickerController alloc]init];
    vc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    [self presentViewController:vc animated:YES completion:nil];
    
}

@end
